package com.ydj.app.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ydj.app.entity.CmsAccount;
import com.ydj.app.protocol.http.cms.*;
import com.ydj.app.service.CsQrCodeService;
import com.ydj.framework.exception.CommonException;
import com.ydj.framework.protocol.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/cms/csQrCode")
@Api(tags = "CMS-客服二维码")
public class CmsCsQrCodeController {

    @Autowired
    private CsQrCodeService csQrCodeService;

    @ResponseBody
    @ApiOperation(value = "列表")
    @ApiOperationSupport(order = 10)
    @PostMapping(value = "/list")
    public JsonResult<CmsCsQrCodeListRes> list(@RequestBody @Validated CmsCsQrCodeListReq req, @ApiIgnore CmsAccount account) throws CommonException {
        CmsCsQrCodeListRes res = csQrCodeService.cmsList(req, account);
        return JsonResult.success(res);
    }

    @ResponseBody
    @ApiOperation(value = "新增")
    @ApiOperationSupport(order = 20)
    @PostMapping(value = "/create")
    public JsonResult<?> create(@RequestBody @Validated CmsCsQrCodeCreateReq req, @ApiIgnore CmsAccount account) throws CommonException {
        CmsCsQrCodeCreateRes res = csQrCodeService.cmsCreate(req, account);
        return JsonResult.success(res);
    }

    @ResponseBody
    @ApiOperation(value = "修改")
    @ApiOperationSupport(order = 30)
    @PostMapping(value = "/update")
    public JsonResult<?> update(@RequestBody @Validated CmsCsQrCodeUpdateReq req, @ApiIgnore CmsAccount account) throws CommonException {
        csQrCodeService.cmsUpdate(req, account);
        return JsonResult.success();
    }

    @ResponseBody
    @ApiOperation(value = "删除")
    @ApiOperationSupport(order = 40)
    @PostMapping(value = "/delete")
    public JsonResult<?> delete(@RequestBody @Validated CmsCsQrCodeDeleteReq req, @ApiIgnore CmsAccount account) throws CommonException {
        csQrCodeService.cmsDelete(req, account);
        return JsonResult.success();
    }

}